package com.sys.basics.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;

import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;
import java.util.List;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.*;

/**
 * @author: ares
 * @date: 2021-09-29
 * @description: 用户管理 实体
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sys_user")
@ApiModel(value = "SysUser对象", description = "用户管理")
public class SysUser implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "默认组织")
    @TableField("default_org_id")
    private Long defaultOrgId;

    @ApiModelProperty(value = "用户名")
    @TableField("username")
    private String username;

    @ApiModelProperty(value = "短码")
    @TableField("shortcode")
    private String shortcode;

    @ApiModelProperty(value = "密码")
    @TableField("password")
    private String password;

    @ApiModelProperty(value = "盐值",hidden = true)
    @TableField("salt")
    private String salt;

    @ApiModelProperty(value = "真实名称")
    @TableField("realname")
    private String realname;

    @ApiModelProperty(value = "用户昵称")
    @TableField("nickname")
    private String nickname;

    @ApiModelProperty(value = "电子邮箱地址")
    @TableField("email")
    private String email;

    @ApiModelProperty(value = "手机号")
    @TableField("mobile")
    private String mobile;

    @ApiModelProperty(value = "状态：0禁用，1启用", hidden=true)
    @TableField("status")
    private Integer status;

    @ApiModelProperty(value = "备注")
    @TableField("remark")
    private String remark;

    @TableField("openid")
    private String openid;

    @ApiModelProperty(value = "用户有效期")
    @TableField("expire_date")
    private LocalDateTime expireDate;

    @ApiModelProperty(value = "乐观锁(版本号)", hidden=true)
    @TableField("version")
    @Version
    private Integer version;

    @ApiModelProperty(value = "创建时间", hidden=true)
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private LocalDateTime gmtCreate;

    @ApiModelProperty(value = "修改时间", hidden=true)
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime gmtModified;

    @ApiModelProperty(value = "创建者id", hidden=true)
    @TableField(value = "creator_id", fill = FieldFill.INSERT)
    private Long creatorId;

    @ApiModelProperty(value = "修改者id", hidden=true)
    @TableField(value = "modifier_id", fill = FieldFill.INSERT_UPDATE)
    private Long modifierId;

    @ApiModelProperty(value = "用户角色", hidden=true)
    @TableField(exist = false) // mybatis plus 注解,. 表明此字段在数据库中不存在
    private SysRole roleInfo;

    @ApiModelProperty(value = "用户默认组织", hidden=true)
    @TableField(exist = false)
    private SysOrg orgInfo;

    @ApiModelProperty(value = "用户资源", hidden=true)
    @TableField(exist = false)
    private List<SysResource> resources;
}
